<link href="<?php echo base_url();?>style/style.css" rel="stylesheet" type="text/css" />
<script src="<?php echo base_url();?>script/jquery.tablesorter.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>script/jquery.uitablefilter.js" type="text/javascript"></script>
<script>
    $(document).ready(function() {
        $("#representativesTable").tablesorter();

      var theTable = $('table.tablesorter')

     /* theTable.find("tbody > tr").find("td:eq(1)").mousedown(function(){
        $(this).prev().find(":checkbox").click()
      });
*/
      $("#filter").keyup(function() {
        $.uiTableFilter( theTable, this.value );
      })
/*
      $('#filter-form').submit(function(){
        theTable.find("tbody > tr:visible > td:eq(1)").mousedown();
        return false;
      }).focus(); //Give focus to input field
*/
   
       //Potvrda za brisenje
        $('.confirmDelete').click(function(){
            var answer = confirm("Are you sure?");
            if(answer){
                window.location = $(this).attr("title");
            }else{
                return;
            }
        });

       //Upload na sliki


    })
</script>
<div class="middleFront">
    <div class="infoText infoTitle">
        Листа на претставници
    </div>
    <div class="questionsHolder">
        <div class="searchboxHolder">
            <table>
                <tr>
                    <td>Барај:</td>
                    <td><input type="text" name="filter" id="filter" class="stiliziran"></td>
                    <td><select class="stiliziran">
                            <option>Избри Општина</option>
                        </select></td>
                    <td><a href="<?php echo (!isset($admin))?base_url().$this->lang->lang().'/representatives/listrepresentatives/all'
                                                     :base_url().'/mk/admin/representatives/listrepresentatives/all'?>">Сите</a></td>
                    <td><a href="<?php echo (!isset($admin))?base_url().$this->lang->lang().'/representatives/listrepresentatives/mps'
                                                     :base_url().'/mk/admin/representatives/listrepresentatives/mps'?>">Пратеници</a></td>
                    <td><a href="<?php echo (!isset($admin))?base_url().$this->lang->lang().'/representatives/listrepresentatives/advisors'
                                                     :base_url().'/mk/admin/representatives/listrepresentatives/advisors'?>">Советници</a></td>
                    <td><a href="<?php echo (!isset($admin))?base_url().$this->lang->lang().'/representatives/listrepresentatives/mayors'
                                                     :base_url().'/mk/admin/representatives/listrepresentatives/mayors'?>">Градоначалници</a></td>
                    </tr>
            </table>
        </div>
        <?php //debug($representatives) ?>
        <table id="representativesTable" class="tablesorter">
            <thead>
                <tr>
                    <th><?php echo lang('firstname')?></th>
                    <th><?php echo lang('lastname')?></th>
                    <th><?php echo lang('rep_role')?></th>
                    <th><?php echo lang('role_from')?></th>
                    <th><?php echo lang('mun_const')?></th>
                </tr>
            </thead>
            <tbody>
                <?php 
                foreach ($representatives as $representative) {
                    echo '<tr>';
                    echo (!isset($admin))?'<td><a href="'.base_url().$this->lang->lang().'/representatives/answers/'.$representative->rep_id.'">'.$representative->rep_name.'</a></td>'
                                  :'<td>'.$representative->rep_name.'</td>';
                    echo (!isset($admin))?'<td><a href="'.base_url().$this->lang->lang().'/representatives/answers/'.$representative->rep_id.'">'.$representative->rep_surname.'</a></td>'
                                  :'<td>'.$representative->rep_surname.'</td>';
                    echo '<td>'.$representative->role_name.'</td>';
                    echo '<td>'.$representative->role_name.'</td>';
                    echo '<td>'.$representative->municipality_name.'</td>';
                    if (isset($admin)) {
                        echo '<td>';
                        echo '<a href="'.base_url().'mk/admin/representatives/editrepresentative/'.$representative->rep_id.'">';
                            echo '<img src="'.base_url().'style/images/edit.png" alt="edit" />';
                        echo '</a>';
                        echo '<a href="javascript://" title="'.base_url().'mk/admin/representatives/deleterepresentative/'.$representative->rep_id.'" class = "confirmDelete">';
                            echo '<img src="'.base_url().'style/images/cancel.png" alt="delete" />';
                        echo '</a>';
                        echo '</td>';
                     }
                    echo '<tr>';
                }
                ?>
            </tbody>
        </table>
    </div>
</div>
